package util.src.com;

import java.io.IOException;

/**
 * @Author: Gosin
 * @Date: 2020/11/10 23:37
 */
public class twoTest extends WriteText{
    public twoTest(String fromPath, String fromName, String toPath, String toName) {
        this.fromPath = fromPath;
        this.fromName = fromName;
        this.toPath = toPath;
        this.toName = toName;
    }

    @Override
    protected String selectUrl(String line) {
        line = line.substring(0,2);
        System.out.println(line);
        return str2HexStr(line);
    }
    /**
     * 字符串转换成为16进制(无需Unicode编码)
     * @param str
     * @return
     */
    public static String str2HexStr(String str) {
        char[] chars = "0123456789ABCDEF".toCharArray();
        StringBuilder sb = new StringBuilder("");
        byte[] bs = str.getBytes();
        int bit;
        for (int i = 0; i < bs.length; i++) {
            bit = (bs[i] & 0x0f0) >> 4;
            sb.append(chars[bit]);
            bit = bs[i] & 0x0f;
            sb.append(chars[bit]);
            // sb.append(' ');
        }
        return sb.toString().trim();
    }

    public static void main(String[] args) throws IOException {
        twoTest a= new twoTest("D:\\xilinx\\fpga_03_pl_fft\\","Data_Input.txt","D:\\xilinx\\fpga_03_pl_fft\\","Data_Input_bak.txt");
        a.getTsUrlText();
    }
}

